#include<bits/stdc++.h>
using namespace std;
int main() {
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    ios::sync_with_stdio(0);
    int T,m,n;
    cin >> n >> m;
    for(int i = 1; i <= n; ++ i)cin >> T;
    for(int i = 1;  i <= m; ++ i) cin >> T;
    int i = ceil(log2(n));
    int a;
    while(i--) {
        cin >> a;
    }
    cin >> T;
    while(T--) {
        cout << 4 << endl;
    }
    return 0;
}
